package com.un.ebs.product.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.un.ebs.core.util.WebResult;
import com.un.ebs.core.util.WebUtils;
import com.un.ebs.product.domain.ProductSkuDoc;
import com.un.ebs.product.domain.SkuDocExt;
import com.un.ebs.product.service.ProductSkuDocService;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (ProductSkuDoc)表控制层
 *
 * @author liubo
 * @since 2020-11-18 13:55:14
 */
@RestController
@RequestMapping("productSkuDoc")
@Api(value = "product-sku-doc")
public class ProductSkuDocController {
    /**
     * 服务对象
     */
    @Resource
    private ProductSkuDocService service;

    @PostMapping(value = "uploadDesign")
    @ApiOperation(value = "上传设计文档")
    public WebResult uploadDesign(@RequestParam(value = "docId", required = false) String docId, @RequestParam(value = "skuId") String skuId, @RequestParam(value = "desc", required = false) String desc, @RequestParam(value = "file") MultipartFile file) {
        service.uploadDesign(docId, skuId, desc, file);
        return WebUtils.success();
    }

    @PostMapping(value = "uploadRelease")
    @ApiOperation(value = "上传发布文档")
    public WebResult uploadRelease(@RequestParam(value = "docId") String docId, @RequestParam(value = "desc", required = false) String desc, @RequestParam(value = "file") MultipartFile file) {
        service.uploadRelease(docId, desc, file);
        return WebUtils.success();
    }

    @PostMapping(value = "submit")
    @ApiOperation(value = "提交")
    public WebResult submit(@RequestParam String id) {
        service.submit(id);
        return WebUtils.success();
    }

    @PostMapping(value = "submitCancel")
    @ApiOperation(value = "提交撤销")
    public WebResult submitCancel(@RequestParam String id) {
        service.submitCancel(id);
        return WebUtils.success();
    }

    @PostMapping(value = "audit")
    @ApiOperation(value = "审核")
    public WebResult audit(@RequestParam String id) {
        service.audit(id);
        return WebUtils.success();
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除")
    public WebResult delete(@RequestParam String id) {
        service.delete(id);
        return WebUtils.success();
    }

    @GetMapping(value = "listDoc")
    @ApiOperation(value = "查询，SkuDoc")
    public WebResult<Page<SkuDocExt>> query(@RequestParam(required = false) String classId, @RequestParam(required = false) String skuCode, @RequestParam Integer pageSize, @RequestParam Integer pageIndex) {
        return WebUtils.success(service.query(classId, skuCode, pageSize, pageIndex));
    }

    @GetMapping(value = "listHistory")
    @ApiOperation(value = "查询，版本历史")
    public WebResult<Page<ProductSkuDoc>> queryHistory(@RequestParam String skuId, @RequestParam Integer pageSize, @RequestParam Integer pageIndex) {
        return WebUtils.success(service.queryHistory(skuId, pageSize, pageIndex));
    }
}